home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / MISC / KINGV3.ZIP / WINEXAM.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-01-02  |  3.0 KB  |  110 lines

  1. Program Windoing_Demo;
  2.   Uses Crt;
  3.   Type
  4.     W_Window = Object
  5.  
  6.       { Variables }
  7.       X,Y,X2,Y2      : Byte;              { Cordinets of window }
  8.       Title          : String[80];        { Title String }
  9.       FCol,BCol      : Byte;              { Window front and back colors }
  10.       TFCol,TBCol    : Byte;              { Title front and back color }
  11.  
  12.       { Methods }
  13.       Procedure Init(XX,YY,XX2,
  14.                 YY2:Byte;Tit:
  15.                 String);                  { Init the window }
  16.       Procedure Draw;                     { Draws the window }
  17.       Procedure SetWColors(F,B:
  18.                 Byte);                    { Set the window colors }
  19.       Procedure SetTColors(F,B:
  20.                 Byte);                    { Set the title colors }
  21.       End;
  22.   Var
  23.     W : W_Window;
  24. (****************************************************************************)
  25.   Procedure W_Window.Init(XX,YY,XX2,YY2:Byte;Tit:String);
  26.     Begin
  27.       X:=XX;
  28.       Y:=YY;
  29.       X2:=XX2;
  30.       Y2:=YY2;
  31.       Title:=Tit;
  32.       FCol:=7;
  33.       BCol:=0;
  34.       TFCol:=15;
  35.       TBCol:=0;
  36.     End;
  37. (****************************************************************************)
  38.   Procedure W_Window.Draw;
  39.     Var
  40.       I : Integer;
  41.     Begin
  42.       TextColor(FCol);
  43.       TextBackGround(BCol);
  44.       GotoXY(X,Y);
  45.       Write('╔');
  46.       For I:=X+1 To X2-1 do Write('═');
  47.       Write('╗');
  48.       For I:=Y+1 To Y2-1 do Begin
  49.         GotoXY(X2,I);
  50.         Write('║');
  51.         End;
  52.       GotoXY(X2,Y2);
  53.       Write('╝');
  54.       For I:=X2-1 DownTo X+1 do Begin
  55.         GotoXY(I,Y2);
  56.         Write('═');
  57.         End;
  58.       GotoXY(X,Y2);
  59.       Write('╚');
  60.       For I:=Y2-1 DownTo Y+1 Do Begin
  61.         GotoXY(X,I);
  62.         Write('║');
  63.         End;
  64.       Window(X+1,Y+1,X2-1,Y2-1);
  65.       ClrScr;
  66.       TextColor(TFCol);
  67.       TextBackGround(TBCol);
  68.       Window(1,1,80,25);
  69.       GotoXY(((X+X2)Div 2)-Length(Title)Div 2,Y);
  70.       Write(Title);
  71.       GotoXY(1,1);
  72.     End;
  73. (****************************************************************************)
  74.   Procedure W_Window.SetWColors(F,B : Byte);
  75.     Begin
  76.       FCol:=F;
  77.       BCol:=B;
  78.     End;
  79. (****************************************************************************)
  80.   Procedure W_Window.SetTColors(F,B : Byte);
  81.     Begin
  82.       TFCol:=F;
  83.       TBCol:=B;
  84.     End;
  85. (****************************************************************************)
  86.   Begin
  87.     TextColor(7);
  88.     TextBackGround(0);
  89.     ClrScr;
  90.     W.Init(20,6,60,12,'Window 1');
  91.     W.Draw;
  92.     TextColor(7);
  93.     TextBackGround(0);
  94.     Write('Press any key to change window colors');
  95.     ReadKey;
  96.     GotoXY(1,1);
  97.     TextColor(7);
  98.     TextBackGround(0);
  99.     Write('Press any key to change title colors  ');
  100.     W.SetWColors(15,0);
  101.     W.Draw;
  102.     ReadKey;
  103.     GotoXY(1,1);
  104.     TextColor(7);
  105.     TextBackGround(0);
  106.     Write('Done!                                      ');
  107.     W.SetTColors(7,0);
  108.     W.Draw;
  109.     ReadKey;
  110.   End.